.class public final Lcom/burstly/lib/exception/UiExceptionHandlerManager;
.super Ljava/lang/Object;
.source "UiExceptionHandlerManager.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/burstly/lib/exception/UiExceptionHandlerManager$1;,
        Lcom/burstly/lib/exception/UiExceptionHandlerManager$UnhandledExceptionWrapper;
    }
.end annotation


# static fields
.field private static final DEBUG_WRAPPER:Lcom/burstly/lib/util/Utils$DebugWrapper; = null

.field private static final TAG:Ljava/lang/String; = "UiExceptionHandlerManager"

.field private static sIsInitialized:Z


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 65
    const-string v0, "UiExceptionHandlerManager"

    invoke-static {v0}, Lcom/burstly/lib/util/Utils$DebugWrapper;->getDebugger(Ljava/lang/String;)Lcom/burstly/lib/util/Utils$DebugWrapper;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/exception/UiExceptionHandlerManager;->DEBUG_WRAPPER:Lcom/burstly/lib/util/Utils$DebugWrapper;

    return-void
.end method

.method private constructor <init>()V
    .locals 0

    .prologue
    .line 115
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 116
    return-void
.end method

.method static synthetic access$000()Lcom/burstly/lib/util/Utils$DebugWrapper;
    .locals 1

    .prologue
    .line 55
    sget-object v0, Lcom/burstly/lib/exception/UiExceptionHandlerManager;->DEBUG_WRAPPER:Lcom/burstly/lib/util/Utils$DebugWrapper;

    return-object v0
.end method

.method public static cleanUp()V
    .locals 1

    .prologue
    .line 163
    invoke-static {}, Lcom/burstly/lib/exception/UiExceptionHandlerManager$UnhandledExceptionWrapper;->access$200()Ljava/util/Set;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/Set;->clear()V

    .line 164
    return-void
.end method

.method public static declared-synchronized init()V
    .locals 5

    .prologue
    .line 122
    const-class v2, Lcom/burstly/lib/exception/UiExceptionHandlerManager;

    monitor-enter v2

    :try_start_0
    sget-boolean v1, Lcom/burstly/lib/exception/UiExceptionHandlerManager;->sIsInitialized:Z

    if-nez v1, :cond_2

    .line 123
    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v0

    .line 124
    .local v0, currentThread:Ljava/lang/Thread;
    invoke-virtual {v0}, Ljava/lang/Thread;->getName()Ljava/lang/String;

    move-result-object v1

    const-string v3, "main"

    invoke-virtual {v1, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-nez v1, :cond_0

    .line 125
    new-instance v1, Ljava/lang/IllegalStateException;

    const-string v3, "Can not initialize manager not in UI thread"

    invoke-direct {v1, v3}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 122
    :catchall_0
    move-exception v1

    monitor-exit v2

    throw v1

    .line 127
    :cond_0
    :try_start_1
    new-instance v1, Lcom/burstly/lib/exception/UiExceptionHandlerManager$UnhandledExceptionWrapper;

    invoke-virtual {v0}, Ljava/lang/Thread;->getUncaughtExceptionHandler()Ljava/lang/Thread$UncaughtExceptionHandler;

    move-result-object v3

    const/4 v4, 0x0

    invoke-direct {v1, v3, v4}, Lcom/burstly/lib/exception/UiExceptionHandlerManager$UnhandledExceptionWrapper;-><init>(Ljava/lang/Thread$UncaughtExceptionHandler;Lcom/burstly/lib/exception/UiExceptionHandlerManager$1;)V

    invoke-virtual {v0, v1}, Ljava/lang/Thread;->setUncaughtExceptionHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V

    .line 129
    sget-boolean v1, Lcom/burstly/lib/constants/Constants;->IS_DEBUG_MODE:Z

    if-eqz v1, :cond_1

    .line 130
    new-instance v1, Lcom/burstly/lib/exception/HeapFileDumpHandler;

    invoke-direct {v1}, Lcom/burstly/lib/exception/HeapFileDumpHandler;-><init>()V

    invoke-static {v1}, Lcom/burstly/lib/exception/UiExceptionHandlerManager;->registerHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V

    .line 132
    :cond_1
    const/4 v1, 0x1

    sput-boolean v1, Lcom/burstly/lib/exception/UiExceptionHandlerManager;->sIsInitialized:Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 134
    :cond_2
    monitor-exit v2

    return-void
.end method

.method public static registerHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V
    .locals 2
    .parameter "handler"

    .prologue
    .line 143
    invoke-static {}, Lcom/burstly/lib/exception/UiExceptionHandlerManager$UnhandledExceptionWrapper;->access$200()Ljava/util/Set;

    move-result-object v1

    invoke-interface {v1, p0}, Ljava/util/Set;->add(Ljava/lang/Object;)Z

    move-result v0

    .line 144
    .local v0, isRegistered:Z
    if-nez v0, :cond_0

    .line 145
    invoke-static {p0}, Lcom/burstly/lib/exception/UiExceptionHandlerManager;->unRegisterHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V

    .line 146
    invoke-static {}, Lcom/burstly/lib/exception/UiExceptionHandlerManager$UnhandledExceptionWrapper;->access$200()Ljava/util/Set;

    move-result-object v1

    invoke-interface {v1, p0}, Ljava/util/Set;->add(Ljava/lang/Object;)Z

    .line 148
    :cond_0
    return-void
.end method

.method public static unRegisterHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V
    .locals 1
    .parameter "handler"

    .prologue
    .line 156
    invoke-static {}, Lcom/burstly/lib/exception/UiExceptionHandlerManager$UnhandledExceptionWrapper;->access$200()Ljava/util/Set;

    move-result-object v0

    invoke-interface {v0, p0}, Ljava/util/Set;->remove(Ljava/lang/Object;)Z

    .line 157
    return-void
.end method
